package spring.spring_affairs.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import spring.spring_affairs.mapper.logInfoMapper;
import spring.spring_affairs.model.logInfo;

@Service
@Transactional(propagation = Propagation.REQUIRES_NEW)
public class logInfoServer {

    @Autowired
    logInfoMapper logInfoMapper;

    public void insertLogInfo(logInfo logInfo) {
        logInfoMapper.insert(logInfo);

//        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

//        抛出异常 自己捕捉了的话就不会再回滚
//        throw new NullPointerException();
//        try {
//            throw new RuntimeException();
//        } catch (RuntimeException e) {
//            //手动回滚当前事务
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//            e.printStackTrace();//打印了堆栈信息
//        }
    }
}
